package sdfi.lee.Properties;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Properties;


public class ReaderProperties {
	private  String filepath="z:/config.properties";
	InputStream is=null;
	Properties p=new Properties();
	public InputStream getIs() {
		return is;
	}
	public void setIs(InputStream is) {
		this.is = is;
	}
	public String getFilepath() {
		return filepath;
	}
	public void setFilepath(String filepath) {
		this.filepath = filepath;
	}
	public 	 ReaderProperties()
	{
		try {
			is=new FileInputStream(this.filepath);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	
	}
	public ReaderProperties(String filepath){
		this.filepath=filepath;
		try {
			is=new FileInputStream(this.filepath);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public String getProperty(String key)throws Exception
	{
		if(is==null)
		is=new FileInputStream(this.filepath);
		
		p.load(is);
		
		return p.getProperty(key);
	}
	public void setProperties(String key,String value) throws Exception
	{ 
		if(is==null)
		is=this.getClass().getClassLoader().getResourceAsStream(filepath);
		p.load(is);
		p.setProperty(key, value);
	}
}
